<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/11/6
 * Time: 14:25
 */

namespace app\admin\common;

//后台公共控制器
use think\Controller;
use think\facade\Session;

class Base extends Controller
{
    // 初始化
    public function initialize()
    {
        $this->isLogin();
    }

    /**
     * 检测用户是否登录
     * 调用位置:
     * 1.后台首页的admin/index/index()
     */
    protected function isLogin(){
        if ( ! Session::has('admin_id')){
            $this->error('请先登录','admin/login/index');
        }
    }

    protected function ifLogin(){
        return Session::has('admin_id');
    }
}